﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using mitasoft.ERS.Web.Utils;

namespace mitasoft.ERS.Web
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UpdateMasterTitle();
        }

        public void UpdateMasterTitle()
        {
            applicationHeader.InnerText = string.Format("ERS - {0}", SessionWrapper.GetFromSession<string>(SessionWrapper.SESSION_CurrentProjectName) ?? "");
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //BindCurrentProject();
        }

        //private void BindCurrentProject()
        //{
        //    ddlSelectedProject.SelectedIndexChanged += new EventHandler(ddlSelectedProject_SelectedIndexChanged);
        //    ddlSelectedProject.DataSource = Utils.CacheFactory.GetProjects;
        //    ddlSelectedProject.DataBind();

        //    int currentProjectID = SessionWrapper.GetFromSession<int>(SessionWrapper.SESSION_CurrentProjectID);

        //    if (currentProjectID > 0)
        //        ddlSelectedProject.SelectedValue = currentProjectID.ToString();
        //    else
        //        ddlSelectedProject.SelectedIndex = 0;

        //    if (!Page.IsPostBack)
        //        SaveSelectedProjectToSession();
        //}

        //void ddlSelectedProject_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    SaveSelectedProjectToSession();
        //}

        //private void SaveSelectedProjectToSession()
        //{
        //    SessionWrapper.AddToSession(
        //        SessionWrapper.SESSION_CurrentProjectID,
        //        Convert.ToInt32(ddlSelectedProject.SelectedValue));
        //}
    }
}
